<?php
	$db_sever="localhost";
	$db_user="root";
	$db_pass="";
	$db_database="alta_mana_media";	
	Connect::ConnectMysql($db_sever, $db_user, $db_pass, $db_database);	
	class Connect{
		private static $databaseLink;		
		public static function CloseConnection(){
			if(self::$databaseLink){
				mysql_close(self::$databaseLink);
			}
		}
		public static function var_array($array){
			$str='';
			if(is_array($array)){
				$num=count($array);
				$str='array('.$num.'){';
				foreach($array as $key =>$val){
					if(is_array($val)){
						$tmpStr=self::var_array($val);
						$str.="['$key']=>$tmpStr,";
					}else{
						$str.="['$key']=>'$val',";
					}
				}
				$str.='}';
			}else{
				$str="'$array',";
			}
			return self::cleanup_text($str);
		}
		
		public static function ConnectMysql($sever,$user,$pass,$database){
			self::CloseConnection();
			self::$databaseLink = mysql_connect($sever,$user,$pass);
			if (!self::$databaseLink){
			  die('Không thể kết nối database ' . mysql_error());
			}
			mysql_select_db($database, self::$databaseLink);
			mysql_query("SET NAMES 'utf8'"); 
		}	
		
		private static function cleanup_text($data)
		{	
			$data= stripslashes($data);    
			$data= mysql_real_escape_string($data);
			//$data=htmlentities($data, ENT_QUOTES, "UTF-8");
			return trim($data);
		} 
}

?>